<template>
	<view>
		<view class="head">
			<view style="font-size: 36rpx;">{{teacher_info.title}}-{{teacher_info.class_course_teacher.course_name}}成绩</view>
			<view style="margin-top: 10rpx;">任课老师：{{teacher_info.class_course_teacher.course_teacher_name}}</view>
			<view class="right">
				<view>找人帮录</view>
			</view>
		</view>
		<view class="head-bottom">
			<view>录入员：{{teacher_info.class_course_teacher.course_teacher_name}}</view>
		</view>
		<view v-for="(item,index) in teacher_info.students" :key="index" class="student">
			<view class="student-list">
				<image :src="item.user.avatar"></image>
				<view class="text-box">
					<view style="font-weight: bold;font-size: 30rpx;">{{item.student.student_name}}</view>
					<view style="font-size: 28rpx;color: #999999;margin-top: 5rpx;">学号：{{item.student.student_no}}</view>
				</view>
				<input @blur="blur(index)" :disabled="course_teacher_id?false:true"  v-model="item.score" placeholder="请输入学生分数" placeholder-style="text-align: right;" :adjust-position="false" />
			</view>
		</view>
		<!-- <view class="submit">
			提交录入
		</view> -->

	</view>
</template>

<script>
	const {
		appLogin,
		httpGet,
		httpPost,
		msg,
		ZC
	} = require("@/utils/common.js")
	const app = getApp()
	export default {
		data() {
			return {
				teacher_info: {},
				course_teacher_id: 0,
			}
		},
		onLoad(e) {
			appLogin((user_info)=>{
				httpGet({
					url: 'users/exam/teacher_info',
					data: {
						exam_id: e.exam_id
					},
				}).then((res) => {
					console.log(res);
					this.teacher_info = res.result
				})
				
				this.course_teacher_id = app.globalData.target_info?app.globalData.target_info.course_teacher_id:''
			})
			
		},
		methods: {
			blur(index){
				if(this.teacher_info.students[index].score == ''){
					uni.showToast({
						title:"请输入分数!",
						icon:'none'
					})
					return
				}
				httpPost({
					url: 'users/exam/set_score',
					passLoading:0,
					data: {
						course_teacher_id: this.course_teacher_id||'',
						exam_score_id:this.teacher_info.students[index].exam_score_id,
						score:this.teacher_info.students[index].score
					},
				}).then((res) => {
				
				})
				
			}

		}
	}
</script>

<style scoped lang="scss">
	.head {
		display: flex;
		height: 360rpx;
		background-color: $m_color;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #ffffff;
		font-size: 32rpx;

		.right {
			position: absolute;
			right: 0;
			top: 20rpx;
			background-color: rgba(0, 0, 0, 0.2);
			border-radius: 50rpx 0 0 50rpx;
			padding: 5rpx 20rpx;
			font-size: 30rpx;
		}
	}

	.head-bottom {
		background-color: #eeeeee;

		view {
			background-color: $m_color;
			border-radius: 100rpx;
			display: inline-block;
			color: #ffffff;
			margin: 20rpx;
			font-size: 28rpx;
			padding: 5rpx 15rpx;
		}
	}

	.student {
		margin: 30rpx 40rpx;
	}

	.student-list {
		display: flex;
		// justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #efefef;
		padding-bottom: 20rpx;

		image {
			height: 100rpx;
			width: 100rpx;
			border-radius: 100rpx;
		}
		.text-box{
			flex-grow: 1;
			padding-left: 30rpx;
		}

		input {
			width: 150rpx;
			height: 80rpx;
			padding: 20rpx 0;
			text-align: right;
		}
	}
</style>
